/*
 * mytime.c
 *
 *  Created on: 2011-1-11
 *      Author: zhang
 */

#include <timer.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

void startTimer(Timer* t){
	gettimeofday(&(t->start),NULL);
}

void endTimer(Timer* t){
	gettimeofday(&(t->end),NULL);
}
double getTimeDiff(Timer* t){
	double timeuse = 1000000 * (t->end.tv_sec - t->start.tv_sec) + t->end.tv_usec - t->start.tv_usec;
	timeuse /= 1000000;
	//double sec = (double) time / CLOCKS_PER_SEC;

  /*
  char filename[100];
  char hostname[100];
  gethostname(hostname,100);
  sprintf(filename,"%s_%s",hostname,"time.dat");
  FILE* f = fopen(filename,"wb");
  fwrite(&timeuse,sizeof(double),1,f);
  fclose(f);*/
}
